﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace SuperFox
{
    public partial class Testimonial : UserControl
    {
        public Testimonial()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(Testimonial),
        new PropertyMetadata("", new PropertyChangedCallback(TextPropertyChanged)));

        public static readonly DependencyProperty NameTextProperty =
            DependencyProperty.Register("NameText", typeof(string), typeof(Testimonial),
        new PropertyMetadata("", new PropertyChangedCallback(NameTextPropertyChanged)));

        public static readonly DependencyProperty CompanyProperty =
            DependencyProperty.Register("Company", typeof(string), typeof(Testimonial),
        new PropertyMetadata("", new PropertyChangedCallback(CompanyPropertyChanged)));

        public static readonly DependencyProperty ImageProperty =
            DependencyProperty.Register("Image", typeof(string), typeof(Testimonial), new PropertyMetadata("",
                                                new PropertyChangedCallback(ImagePropertyChanged)));

        public string Image
        {
            get { return (string)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public string NameText
        {
            get { return (string)GetValue(NameTextProperty); }
            set { SetValue(NameTextProperty, value); }
        }

        public string Company
        {
            get { return (string)GetValue(CompanyProperty); }
            set { SetValue(CompanyProperty, value); }
        }

        private static void NameTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as Testimonial).TitleTb.Text = (string)e.NewValue;
        }

        private static void CompanyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as Testimonial).NameTb.Text = (string)e.NewValue;
        }

        private static void TextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as Testimonial).BodyTb.Text = (string)e.NewValue;
        }

        private static void ImagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as Testimonial).LogoImg.Source = new BitmapImage(new Uri((string)e.NewValue, UriKind.RelativeOrAbsolute));
        }
    }
}
